package com.bwei.like.mostitemnews.fragmentFactory;

import android.support.v4.app.Fragment;

import com.bwei.like.mostitemnews.fragment.MilitaryFragment;
import com.bwei.like.mostitemnews.fragment.MyFragment;

import java.util.HashMap;

/**
 * Created by LiKe on 2016/11/22.
 */
public class FragmentFactory {
    private static HashMap<String, Fragment> hashMap = new HashMap<>();

    public static Fragment getFragment(String title) {
        Fragment fragment = hashMap.get(title);
        if (fragment != null) {
            return fragment;
        }

        if (title.equals("军事")) {
            fragment = new MilitaryFragment();
        } else {
            fragment = MyFragment.getFragment(title);
        }
        hashMap.put(title, fragment);
        return fragment;
    }
}
